let net = require('net')

process.stdin.resume()
process.stdin.setEncoding('utf8')

let port = 8088
let sockets = []

let client = net.connect({
    port
}, () => {
    console.log('Contented to server')

    console.log('input: ')
    process.stdin.on('data', data => {
        console.log('input: ')
        client.write(data)

        if (data === 'close\n') {
            client.end()
        }
    })
})
client.on('data', data => {
    console.log('Other user\'s input ', data.toString())
})

client.on('end', () => {
    console.log('Disconnected from server')
    process.exit()
})